package home.projects.aop.runner;

import home.projects.aop.components.TestComponent;

import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

import org.apache.commons.chain.impl.ContextBase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

   public static void main(final String[] args) throws Exception {
      ApplicationContext ctx = new ClassPathXmlApplicationContext(
            "home/projects/aop/config/context-beans.xml");
      ctx.getBean("testComponent");
      TestComponent tc = new TestComponent();
      tc.execute(new ContextBase());
      new SimpleDateFormat("yyyy").format(new Date()); 
      InputStream in = Main.class.getClassLoader().getResourceAsStream(
            "data/data.properties");
      byte[] b = new byte[1024];
      in.read(b);
      in.close();
      System.out.println(new String(b));
      ResourceBundle bundle = ResourceBundle.getBundle("data/data");
      System.out.println(bundle.getString("name"));
   }

}
